<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	/**
	 功能名称:在本年度中为班级设置班主任
	 
	 @author:
	 **/
%>
<%
String path = request.getContextPath();
%>
<html>
  <head>
    <title>班主任安排</title>
    <link href="css/index_css.css" rel="stylesheet" type="text/css" />
	<script src="<%=path%>/js/resizeIframe.js" type="text/javascript"></script>
	<script language="javascript" src="<%=path %>/js/syAjax.js"></script>
    <script src="<%=path%>/dwr/engine.js"></script>
	<script src="<%=path%>/dwr/util.js"></script>
	<script src="<%=path%>/dwr/interface/shiyueDwr.js"></script>
    <script type="text/javascript">
       window.onload = function(){
      	
      	resizeIframe();
        new Anim.DD($("items"), $("title"));
		$("items").style.left = "50px";
		$("items").style.top = "100px";
          
        
        load();
        }
    var objectTD;
	var objectHIDDENID;
	var orgId;
	function giveParamArr(){
		return document.getElementById(objectHIDDENID).value;
	}


      //显示遮罩
      function displayModuleDiv(){
		document.getElementById("items").style.display = "";	
		resizeIframe();
	}
	
	//关闭div
	function closeDIV(){
		document.getElementById("items").style.display = "none";
	}
        function go(url)
        {
        window.location.href=url;
        }
        
        function goValue(year)
        {
        window.location.href="<%=path%>/classLeaderUserAction.action?year="+year;
        }
        
        function getAllYearCallBack(yearMap) {
        DWRUtil.addOptions("year", yearMap);
        if('${currentYear}'!="")
	    {
	      if('${selectYear}'!='')
	      {
	        document.getElementById("year").value="${selectYear}";
	      }else{
	        document.getElementById("year").value="${currentYear}";
	      }
	    }
    } 
    
 
    
    function load()
    {
    	shiyueDwr.getAllYear(getAllYearCallBack);
    	
    }
	function tdClick(url)
    {
      window.location.href=url;
    }
    function doChooseUser(returnStr){
	//原版内容
		var idStr;
		if(returnStr==undefined){
			return;
		}
		if(returnStr!=null && returnStr!=""){
			var UserArr = returnStr.substring(0,returnStr.length-1).split(",");
			var UserNameStr="";
			for(var i=0;i<UserArr.length;i++){
				var user=UserArr[i];
				var sonArr=user.split("_");
				if((i+1)%5==0){
					UserNameStr+="&nbsp;&nbsp;"+sonArr[1]+"&nbsp;&nbsp;"+"<input name=\"ppp"+orgId+"\" type=\"hidden\" value=\""+sonArr[0]+"\"/><br>";
				}else{
					UserNameStr+="&nbsp;&nbsp;"+sonArr[1]+"&nbsp;&nbsp;"+"<input name=\"ppp"+orgId+"\" type=\"hidden\" value=\""+sonArr[0]+"\"/>";	
				}
				idStr+=sonArr[0]+",";
			}
			document.getElementById(objectHIDDENID).value=idStr;
			if(UserNameStr!=""){									
				document.getElementById('div'+orgId).innerHTML=UserNameStr;					
			}	
		}else{
			document.getElementById('div'+orgId).innerHTML="<font color=\"red\">此班级暂无班主任</font>";
		}
		closeDIV();
	}  
	function showModel2(classId){
		orgId=classId;
		objectHIDDENID="p"+orgId;
		if(document.getElementById('year').value=='${applicationScope.currentYear}')
	   {
			var actionUrl="setClassLeaderorganizationAction.action?cla.classId="+classId+"&ttt"+new Date();
			document.getElementById("selectUserIframe").src="<%=path%>/toSelectTeacherorganizationAction.action?years=${applicationScope.currentYear}&role.roleId=bzr&actionURL="+actionUrl;
			displayModuleDiv();
		}else{
		   alert("不是当前年度，不能进行此操作！");
		}
	}
    </script>
  </head>
  <body>
  <div id="contentDIV" style="position:absolute;width:100%; padding:5px; background-color:#ffffff;z-index:1;">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2" align="left" class="f_5">岗位安排</td>
  </tr>
  <tr>
    <td height="1" colspan="2" bgcolor="#9DD12E"></td>
  </tr>
  <tr>
    <td colspan="2" align="left" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" align="left"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="left" valign="bottom" background="images/sywesp_24.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="80" align="left"><table width="80" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="1" align="left" valign="bottom" bgcolor="#CBCBCB"></td>
                <td align="center" background="images/sywesp_18.gif" class="f_6" onclick="tdClick('getAllCourseByGradeIdGradeAndClassAction.action?gradeCourse.id.grade.gradeId=1&year=${currentYear }');" style="cursor:pointer;">任课安排</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table></td>
            <td width="90" align="left"><table width="90" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="center" background="images/sywesp_25.gif" class="f_9">班主任安排</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table></td>
            <td width="100" align="left"><table width="100" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="center" background="images/sywesp_18.gif" class="f_6" onclick="tdClick('gradeSubjectTeamLeaderorganizationAction.action?role.roleId=bkzz&years=${currentYear }');" style="cursor:pointer;">备课组长安排</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table></td>
            <td width="100" align="left"><table width="100" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="center" background="images/sywesp_18.gif" class="f_6" onclick="tdClick('subjectTeamLeaderorganizationAction.action?role.roleId=jyzz&year.name=${currentYear }');" style="cursor:pointer;">教研组长安排</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table></td>
            <td width="100" align="left"><table width="100" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="center" background="images/sywesp_18.gif" class="f_6" onclick="tdClick('toGradeTeamLeaderGradeAndClassAction.action?year=${currentYear }&role.roleId=njzz');" style="cursor:pointer;">年级组长安排</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table></td>
            <td width="110" align="left"><table width="110" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="center" background="images/sywesp_18.gif" class="f_6" onclick="tdClick('departmentLeaderorganizationAction.action?role.roleId=bmfzr&year.name=${currentYear }');" style="cursor:pointer;">部门负责人安排</td>
                <td width="1" height="31" align="right" valign="bottom" bgcolor="#CBCBCB"></td>
              </tr>
            </table></td>
            <td align="left">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td align="left" valign="top" class="tb_8 border_2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="25" align="left" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="38%" align="left">按年度查询：
                  <label>
                  <select name="select2" id="year" onchange="javascript:goValue(this.value);">
                  </select>
                  </label>
                  <br /></td>
                <td width="46%" align="right" valign="top">&nbsp;</td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td align="left" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#DCDCDC">
              <tr>
                <td width="8%" height="30" align="left" bgcolor="#DBE9F6" class="f_4" nowrap="nowrap">&nbsp;班级名称</td>
                <td align="left" bgcolor="#DBE9F6" class="f_4">&nbsp;班主任</td>
                </tr>
              <tr>
                <c:choose>
              <c:when test="${!empty AllClassByunit}">
	          <c:forEach items="${AllClassByunit}" var="cla">
	          <c:set value="" var="totalArr"></c:set>
              <tr>
                <td height="30" bgcolor="#FFFFFF" class="f_4" nowrap="nowrap"> &nbsp;${cla.name }</td>
                <td width="92%" align="left" bgcolor="#FFFFFF" style="cursor:pointer;" onclick="showModel2('${cla.classId }')" onmouseover="this.style.backgroundColor='#e4f5ff'" onmouseout="this.style.backgroundColor=''">
                <span id="div${cla.classId}">
                <c:choose>
                <c:when test="${! empty porid[cla.classId]}">
                <c:forEach items="${porid[cla.classId]}" var="user" varStatus="i" begin="0" step="1">
                <c:set value="${user.userId},${totalArr }" var="totalArr"></c:set>
                <c:if test="${i.count%5==0}">
	        		&nbsp;&nbsp;${user.name }&nbsp;&nbsp;<input name="ppp${cla.classId}" type="hidden" value="${user.userId }"/><br>
	        	</c:if>
	        	<c:if test="${i.count%5!=0}">
	        		&nbsp;&nbsp;${user.name }&nbsp;&nbsp;<input name="ppp${cla.classId}" type="hidden" value="${user.userId }"/>
	        	</c:if>
                
                </c:forEach>
                </c:when>
                <c:otherwise>
                <font color="red">此班级暂无班主任</font>
                </c:otherwise>
                </c:choose>
                </span>
                <input type="hidden" id="p${cla.classId}" value="${totalArr }"/>
                </td>
              </tr>
              </c:forEach>
              </c:when>
              <c:otherwise>
	              <tr>
	              <td colspan="2" class="f_4" align="center"><font color="red">暂无班级信息</font></td>
	              </tr>
              </c:otherwise>
              </c:choose>
              </tr>
            </table></td>
          </tr>
        </table>
          </td>
      </tr>
      <tr>
        <td height="400">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
</table>
</div>
<div id="items" style="position: absolute; width: 730px;height:600px; top:100px; left:200px; padding-bottom:8px; background-color:#ECF7FD;z-index:10; border:3px solid #3A6EA5; display: none;" >
	<div style="width:100%;top:100px;left:200px;" id="title">
		<table border="0" width="100%" cellpadding="0" cellspacing="0" align="center" bgcolor="#3A6EA5">
						<tr style=" height: 30px;">
		<td>&nbsp;&nbsp;<font color='#FFFFFF'>请选择教师</font></td>
		<td align="right"><a href="javascript:closeDIV();" style="text-decoration: none;"><span style="color: #000000; font-size:;">[关闭]</span></a></td>
						</tr>
		</table>
	</div>
	<div style="width:100%;top:100px;left:200px;height: 100%">
	<iframe name="selectUserIframe" id="selectUserIframe" src="" style="width:100%;height: 100%" align="middle"  frameborder="0"></iframe>   
	</div>
		
</div>
  </body>
</html>
